package com.example.pojo;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Past;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2024-03-03
 * Time: 14:49
 *
 * 参数校验注解
 * 必须 setter 和 getter 方法，否则校验不生效
 */
@Data
//@AllArgsConstructor
//@NoArgsConstructor
public class User {

    @NotBlank // 不为空
    private String name;

    @Length(min = 6, max = 16) // 长度范围
    private String password;

    @Min(1) // 大于等于1
    private int age;

    @Email // 邮箱
    private String email;

    @Past // 日期
    private Date birthday;
}
